package com.niuxiaofa.newlaw.Fragment;

import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.niuxiaofa.newlaw.Activity.CashActivity;
import com.niuxiaofa.newlaw.Activity.CustomerServiceActivity;
import com.niuxiaofa.newlaw.Activity.MyClassActivity;
import com.niuxiaofa.newlaw.Activity.MyCollectionActivity;
import com.niuxiaofa.newlaw.Activity.MyCreditsActivity;
import com.niuxiaofa.newlaw.Activity.MyOrderActivity;
import com.niuxiaofa.newlaw.Activity.MyRewardActivity;
import com.niuxiaofa.newlaw.Activity.PersonalHomeActivity;
import com.niuxiaofa.newlaw.Activity.RechargeKnowledgeActivity;
import com.niuxiaofa.newlaw.Activity.SettingActivity;
import com.niuxiaofa.newlaw.Activity.VipCenterActivity;
import com.niuxiaofa.newlaw.Base.BaseFragment;
import com.niuxiaofa.newlaw.Bean.UserInfoBean;
import com.niuxiaofa.newlaw.Network.UserPresenter;
import com.niuxiaofa.newlaw.R;
import com.niuxiaofa.newlaw.Tools.Constant;
import com.niuxiaofa.newlaw.Tools.GlideUtils;
import com.niuxiaofa.newlaw.Tools.ToActivityUtil;
import com.niuxiaofa.newlaw.Tools.UIUtils;
import com.niuxiaofa.newlaw.View.ShareDialog;

import butterknife.BindView;

public class MeFragment extends BaseFragment implements UserPresenter.interface_userInfo {


    @BindView(R.id.username)
    TextView username;

    @BindView(R.id.user_img)
    ImageView userimage;

    @BindView(R.id.knowCoin)
    TextView knowCoin;

    @BindView(R.id.energy)
    TextView energy;

    @BindView(R.id.credit)
    TextView credit;

    @BindView(R.id.person_page)
    TextView person_page;

    @BindView(R.id.shimmerlinearview)
    LinearLayout shimmerlinearview;


    @BindView(R.id.recharge_knowCoin)
    LinearLayout recharge_knowCoin;


    @BindView(R.id.mycredits)
    LinearLayout mycredits;

    @BindView(R.id.mysetting)
    LinearLayout mysetting;


    @BindView(R.id.my_balance)
    LinearLayout my_balance;


    @BindView(R.id.myorder)
    LinearLayout myorder;


    @BindView(R.id.myreward)
    LinearLayout myreward;


    @BindView(R.id.my_class)
    LinearLayout my_class;

    @BindView(R.id.my_collection)
    LinearLayout my_collection;

    @BindView(R.id.customer)
    LinearLayout customer;
    @BindView(R.id.share)
    LinearLayout share;

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_me;
    }

    @Override
    public void initData() {
        UserPresenter.userInfo(this);

        person_page.setOnClickListener(e -> {
            ToActivityUtil.toNextActivity(PersonalHomeActivity.class);

        });
        shimmerlinearview.setOnClickListener(e -> {

            ToActivityUtil.toNextActivity(VipCenterActivity.class);
        });

        //求知币充值
        recharge_knowCoin.setOnClickListener(e -> {
            ToActivityUtil.toNextActivity(RechargeKnowledgeActivity.class);
        });


        mycredits.setOnClickListener(e -> {
            ToActivityUtil.toNextActivity(MyCreditsActivity.class);
        });

        mysetting.setOnClickListener(e -> {

            ToActivityUtil.toNextActivity(SettingActivity.class);

        });
        my_balance.setOnClickListener(e -> {

            ToActivityUtil.toNextActivity(CashActivity.class);
        });

        myorder.setOnClickListener(e -> {
            ToActivityUtil.toNextActivity(MyOrderActivity.class);

        });

        myreward.setOnClickListener(e -> {
            ToActivityUtil.toNextActivity(MyRewardActivity.class);

        });
        my_class.setOnClickListener(e -> {

            ToActivityUtil.toNextActivity(MyClassActivity.class);
        });

        my_collection.setOnClickListener(e -> {
            ToActivityUtil.toNextActivity(MyCollectionActivity.class);
        });

        share.setOnClickListener(e -> {
            ShareDialog shareDialog = new ShareDialog();
            shareDialog.setDialog(UIUtils.getActivity(), "http://www.niuxf.com/", "牛晓法");
        });

        customer.setOnClickListener(e -> {
            ToActivityUtil.toNextActivity(CustomerServiceActivity.class);
        });


    }


    @Override
    public void getResponse(UserInfoBean u) {

        if (u.getCode() == 1) {
            username.setText(u.getData().getUserName());
            GlideUtils.loadChatImage(getContext(), u.getData().getHeader(), userimage);
            knowCoin.setText(u.getData().getKnowCoin() + "");
            energy.setText(u.getData().getEnergy() + "");
            credit.setText(u.getData().getCredit() + "");
            Constant.userInfoBean = u.getData();
            // balance.setText(u.getData().getBalance()+"");

        }

    }


}
